/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __CORE_H__
#define __CORE_H__

#include "Window.h"

#include "IScene.h"
#include "Logfile.h"
#include "IModule.h"
#include "Thread.h"

/**
 *  Windows message procedures
 */
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam );


/**
 *  Initialize the core and create a window
 *  @param width	The width of the window
 *  @param height	The height of the window
 *  @param depth	The pixel depth for the window
 *  @param fullscreen	Indicates if a fullscreen window should be created
 *  @param renderer	The renderer to use. Possible values are CORE_DIRECTX or CORE_OPENGL. 
 *					CORE_OPENGL needs to be implemented.
 */
DLL_EXPORT 
bool coreInitVideo(int width, int height, int depth, bool fullscreen, int renderer, bool vsync = false);

/**
 *  Add a module to the core. 
 *  Modules integrate into the update / rendering cycle and the event handling system (i.e. IAudio, IInputHandler)
 *  @param module	The module to add to the core
 */
DLL_EXPORT 
void coreAddModule( IModule* module );


/**
 *  Initializes a scene and sets the rendering loop to use the scene
 *  @param scene	The new scene to render
 */
DLL_EXPORT
void coreSetScene(IScene *scene);

/**
 *  Starts the core rendering loop
 */
DLL_EXPORT 
void coreRun();

/**
 *  Shutdown the core
 */
DLL_EXPORT
void coreShutdown();

/** 
 *  Add an WNDPROC of your own liking 
 *  @param eventFunc a custom WNDPROC function
 */
DLL_EXPORT
void coreAddCustomEventHandler( WNDPROC eventFunc );


DLL_EXPORT 
void coreSetRunning( bool running );

/**
 *  Enables / Disables the rendering loop
 */
DLL_EXPORT
void coreSetRendering( bool rendering );

DLL_EXPORT
const std::string coreGetWorkingDirectory();

#ifndef __MUTEX
#define __MUTEX
/// A global mutex
static thread::Mutex g_mutex;
#endif

#endif
